var webpack = require('webpack');
var path = require("path");
var ExtractTextPlugin = require("extract-text-webpack-plugin");

module.exports = {
    //插件项
    plugins: [
        new webpack.optimize.CommonsChunkPlugin('common'),//提取多个入口文件的公共脚本部分，然后生成一个 common.js 来方便多页面之间进行复用
        new webpack.ProvidePlugin({
            // Promise:'es6-promise',
        }),
        new webpack.optimize.UglifyJsPlugin({
            compress: {warnings: false}
        }),
        new ExtractTextPlugin("styles.css"),
    ],
    //页面入口文件配置
    entry: {
        /* 全局文件 */
        'global' : "src/global.vue",

        /* 组件页面文件 */
        'components/order-detail' : "src/components/order-detail.vue",
        'components/order-list' : "src/components/order-list.vue",

        /* 项目页面文件 */
        'auth/register' : "src/auth/register.vue",
        'auth/smsVerify' : "src/auth/smsVerify.vue",

        'master/detail' : "src/master/detail.vue",
        'master/changePhone' : "src/master/changePhone.vue",
        'master/changeArea' : "src/master/changeArea.vue",
        'master/changeServiceType' : "src/master/changeServiceType.vue",
        'master/changeServiceAreas' : "src/master/changeServiceAreas.vue",
        'master/changeServicePeriod' : "src/master/changeServicePeriod.vue",
        'master/changeServiceExtra' : "src/master/changeServiceExtra.vue",
        'master/changeJobType' : "src/master/changeJobType.vue",

        'wallet/password' : "src/wallet/password.vue",
        'wallet/cashStart' : "src/wallet/cashStart.vue",
        'wallet/assureFund' : "src/wallet/assureFund.vue",

        'refund/detail' : "src/refund/detail.vue",

        'order/offeringList' : "src/order/offeringList.vue",
        'order/offerStart' : "src/order/offerStart.vue",
        'order/listMasterOffered' : "src/order/listMasterOffered.vue",
        'order/detail' : "src/order/detail.vue",
        'order/appoint' : "src/order/appoint.vue",
        'order/delivery' : "src/order/delivery.vue",
        'order/finish' : "src/order/finish.vue",
    },
    //入口文件输出配置
    output: {
        path: path.join(__dirname, "public/dist"),
        publicPath: '/dist/',
        filename: '[name].js',
    },
    module: {
        //加载器配置
        loaders: [
            // { test: /\.css$/, loader: 'style-loader!css-loader' },
            { test: /\.css$/, loader: ExtractTextPlugin.extract({ fallback: 'style-loader', use: 'css-loader' }) },
            { test: /\.js$/, loader: 'jsx-loader?harmony' },
            // { test: /\.(png|jpg)$/, loader: 'url-loader?limit=8192&name=images/[name].[hash:8].[ext]'},
            { test: /\.(png|jpg)$/, loader: 'url-loader?limit=8192&name=images/[name].[ext]'},
            { test: /\.vue/, loader: 'vue-loader' },
        ]
    },
    resolve: {
        alias: {
            /* 公用路径 */
            assets: path.resolve(__dirname, "resources/assets"),
            src: path.resolve(__dirname, "resources/assets/src"),
            components: path.resolve(__dirname, "resources/assets/src/components"),
            libs: path.resolve(__dirname, "resources/assets/src/libs"),

            /* 组件类库 */
            areas : path.resolve(__dirname, "resources/static/areas.js"),
            'area-selector' : "components/area-selector.vue",
            'mobile-handle' : "components/mobile-handle.vue",
            'wallet-handle' : "components/wallet-handle.vue",

            /* 全局类库 */
            jquery : 'libs/jquery-3.1.1.min.js',
            vue : 'libs/vue.js',
            axios : 'libs/axios.min.js',
            lodash : 'libs/lodash.min.js',
            'es6-promise' : 'libs/es6-promise.min.js',
            bootstrap : 'libs/bootstrap.min.js',
            'jquery-validate' : 'libs/jquery-validation/jquery.validate.min.js',
        }
    },
    externals: {
        // _: true,//lodash
        // $: true,//jquery
        // jQuery: true,//jquery
        // Promise:true,
        // Vue:true,
        // axios: true,//axios
        // moment:true,
    }
};